package com.teamwings.common.aspect;

import com.teamwings.common.aspect.annotation.FormControl;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;

import java.util.Set;

public class FindFormControlClassPathScanHandle extends ClassPathBeanDefinitionScanner {

    public FindFormControlClassPathScanHandle(BeanDefinitionRegistry registry, boolean useDefaultFilters) {
        super(registry, useDefaultFilters);
    }

    @Override
    protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
        //添加过滤条件，这里是只添加了@FormControl的注解才会被扫描到
        addIncludeFilter(new AnnotationTypeFilter(FormControl.class));
        //调用spring的扫描
        return super.doScan(basePackages);
    }
}
